//
//  UIButton+Extension.swift
//  微博项目
//
//  Created by Mac on 2017/5/14.
//  Copyright © 2017年 Mac. All rights reserved.
//

import UIKit

extension UIButton {
    // 类方法
//    class func createBtn(imageName:String, bgImageName:String) -> UIButton{
//        let composeBtn = UIButton()
//        // 设置属性
//        composeBtn.setImage(UIImage.init(named:imageName), for:.normal)
//        composeBtn.setImage(UIImage.init(named: imageName + "_highlighted"), for:.highlighted)
//        composeBtn.setBackgroundImage(UIImage.init(named:bgImageName), for:.normal)
//        composeBtn.setBackgroundImage(UIImage.init(named: bgImageName + "_highlighted"), for: .highlighted);
//        // 根据图片的尺寸调整大小
//        composeBtn.sizeToFit()
//        return composeBtn
//    }
    
    convenience init(imageName:String,bgImageName:String){
        self.init()
        // 设置属性
        self.setImage(UIImage.init(named:imageName), for:.normal)
        self.setImage(UIImage.init(named: imageName + "_highlighted"), for:.highlighted)
        self.setBackgroundImage(UIImage.init(named:bgImageName), for:.normal)
        self.setBackgroundImage(UIImage.init(named: bgImageName + "_highlighted"), for: .highlighted);
        // 根据图片的尺寸调整大小
        self.sizeToFit()
    }
}
